import request from '@/utils/request'

// 获取商品类别
export function getCategorys(query) {
  return request({
    url: '/categorys',
    method: 'GET',
    params: query
  })
}
// 添加商品类别
export function addCategory(data) {
  return request({
    url: '/category/add',
    method: 'POST',
    data
  })
}
// 根据id获取商品类别
export function getCategoryById(id) {
  return request({
    url: `/category/${id}`,
    method: 'GET'
  })
}
// 根据关键字获取商品类别
export function getCategoryByKeyWords(query) {
  return request({
    url: '/category/keywords',
    method: 'GET',
    params: query
  })
}
// 根据id修改商品类别
export function updateCategoryById(id, data) {
  return request({
    url: `/category/update/${id}`,
    method: 'PUT',
    data
  })
}
// 删除商品类别
export function deleteCategory(id) {
  return request({
    url: `/category/delete/${id}`,
    method: 'PUT'
  })
}
export default {
  getCategorys,
  addCategory,
  getCategoryById,
  updateCategoryById,
  getCategoryByKeyWords,
  deleteCategory
}